/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

using ll = long long;

constexpr int maxn = 1e4, mod = 1e9 + 7;

ll qpow(ll base, int exp) {
  ll res = 1;
  while (exp) {
    if (exp & 1) res = res * base % mod;
    base = base * base % mod;
    exp >>= 1;
  }
  return res;
}

ll frac[maxn + 1], invf[maxn + 1];

ll binom(int n, int m) { return frac[n] * invf[n - m] % mod * invf[m] % mod; }

int e[maxn + 1];
ll f[maxn + 1];

int main() {
  int n, k, maxe = 0;
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> e[i];
    maxe = std::max(maxe, e[i]);
  }
  frac[0] = 1;
  for (int i = 1; i <= n; ++i) {
    frac[i] = frac[i - 1] * i % mod;
  }
  invf[n] = qpow(frac[n], mod - 2);
  for (int i = n - 1; i >= 0; --i) {
    invf[i] = invf[i + 1] * (i + 1) % mod;
  }
  f[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= maxe; ++j) {
      f[j] += f[j - 1];
      if (f[j] >= mod) f[j] -= mod;
    }
  }
  ll ans = 0;
  for (int i = 0; i <= n; ++i) {
    ll product = 1;
    for (int j = 1; j <= k; ++j) {
      product = product * f[e[j]] % mod;
    }
    product = product * binom(n, i) % mod;
    if (i & 1) product = (mod - product) % mod;
    ans += product;
    if (ans >= mod) ans -= mod;

    for (int j = 1; j <= maxe; ++j) {
      f[j] = (f[j] - f[j - 1] + mod) % mod;
    }
  }
  cout << ans << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("Ex - Avoid Square Number.in", "r", stdin);
  freopen("Ex - Avoid Square Number.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
